package com.Maybe.book.model;

import com.Maybe.book.enums.ResultStatusEnum;
import lombok.Data;

@Data
public class Result<T> {
//    private int status;
    private ResultStatusEnum status;//注意status的返回类型是ResultStatusEnum
    private String errorMessage;
    private T data;//指的是结果
    
    public static <T> Result success(T data){
        Result result=new Result();
        result.setStatus(ResultStatusEnum.SUCCESS);
        result.setErrorMessage("");
        result.setData(data);
        return result;
    }

//    private void setStatus(ResultStatusEnum success) {
//    }

    public static Result fail(String msg){
        Result result=new Result();
        result.setStatus(ResultStatusEnum.FAIL);
        result.setErrorMessage("msg");
        result.setData("");
        return result;
    }
    public static  Result unlogin(){
        Result result=new Result();
        result.setStatus(ResultStatusEnum.UNLOGIN);
        result.setErrorMessage("用户未登陆");
        result.setData(null);
        return result;
    }
}
